package psrc.logic.pages.base;


import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * Classe base para outras classes Controller
 */
public abstract class ControllerBase extends ActionSupport {

	private static final long serialVersionUID = 1L;

	@Override
	public String execute() throws Exception {

		try {
			Map session = ActionContext.getContext().getSession();
			if (!session.containsKey("logined") || !session.get("logined").equals("true")){
				System.out.println("There is not an authenticated user in system. Redirecting to login page");
				return LOGIN;
			}
			return executeController();
		} catch (Exception e) {
			e.printStackTrace();
			return "genericError";
		}
	}

	public abstract String executeController() throws Exception;
}
